package com.atguigu.gmall.gmallsugar.mapper;

import com.atguigu.gmall.gmallsugar.bean.VisitorStats;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface VisitorMapper {
    @Select("SELECT\n" +
        "    toHour(stt) hour,\n" +
        "    sum(pv_ct) pv_ct,\n" +
        "    sum(uv_ct) uv_ct,\n" +
        "    sum(uj_ct) uj_ct\n" +
        "FROM visitor_stats_2021\n" +
        "WHERE toYYYYMMDD(stt) = #{date}\n" +
        "GROUP BY toHour(stt)\n")
    List<VisitorStats> statsByHour(@Param("date") int date);
    
    @Select("SELECT\n" +
        "    is_new,\n" +
        "    sum(pv_ct) pv_ct,\n" +
        "    sum(uv_ct) uv_ct,\n" +
        "    sum(uj_ct) uj_ct\n" +
        "FROM visitor_stats_2021\n" +
        "WHERE toYYYYMMDD(stt) = #{date}\n" +
        "GROUP by is_new\n")
    List<VisitorStats> statsByIsNew(@Param("date") int date);
    
    
    
}
